#include <iostream>
#include <cmath>
#include <algorithm>
#include <cstring>
#include <vector>
#include <map>
#include <queue>
#include <cstdio>
#include <string>
#include <stack>
#include <set>
#define IOS ios::sync_with_stdio(false), cin.tie(0)
using namespace std;
typedef long long ll;
const ll mod=(1e+9)+7;
ll f(ll a,ll b){
    ll sum=0;
    while(b){
        if(b&1){
            sum=(sum+a)%mod;
        }
        b>>=1;
        a=(a+a)%mod;
    }
    return sum;
}
ll n,m;
int main()
{
    IOS;
    cin>>m>>n;
    if(m<n)swap(m,n);
    if(n%2==0){
        cout<<f(n/2,(2*m-n+1))<<endl;
    }
    else cout<<f(n,(2*m-n+1)/2)<<endl;
    getchar();
    getchar();
    return 0;
}
